/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __MSG_AIO_AIO_UDP_H__
#define __MSG_AIO_AIO_UDP_H__

namespace xos_net
{
    class data;
    class udp;

    class aio_udp
    {
    public:
        aio_udp();
        ~aio_udp();

    public:
        int post_init( xos_box::i_msg *& pMsg, connection * pConnect );
        int post_send( xos_box::i_msg *& pMsg, connection * pConnect, xos_box::i_list * pList, const char * lpszIp, int nPort, bool bCloseAfterSend, bool bQuitAfterSend );
        int post_send( xos_box::i_msg *& pMsg, connection * pConnect, xos_box::i_buf *& pBuf, const char * lpszIp, int nPort, bool bCloseAfterSend, bool bQuitAfterSend );
        int post_shutdown( xos_box::i_msg *& pMsg, connection * pConnect, int how );
        int post_close( xos_box::i_msg *& pMsg, connection * pConnect, bool bNotifyIfAlreadyClosed );

    protected:
        int post_close( xos_box::i_msg *& pMsg, connection * pConnect, int onoff, int linger, bool bNotifyIfAlreadyClosed );
        int on_init( xos_box::i_msg *& pMsg );
        int on_recv( xos_box::i_msg *& pMsg );
        int on_send( xos_box::i_msg *& pMsg );
        int on_shutdown( xos_box::i_msg *& pMsg );
        int on_close( xos_box::i_msg *& pMsg );

    public:
        int proc( xos_box::i_msg *& pMsg );

    };

} // xos_net

#endif // __MSG_AIO_AIO_UDP_H__
